package com.ruoyi.statisticalCenter.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.domain.vo.TableVo;
import com.ruoyi.statisticalCenter.domain.ScHqSysHqBillOne;
import com.ruoyi.statisticalCenter.domain.ScHqSysHqBillTwo;
import com.ruoyi.statisticalCenter.domain.vo.ScHqSysHqBillOneVo;
import com.ruoyi.statisticalCenter.domain.vo.ScHqSysHqBillTwoVo;
import com.ruoyi.statisticalCenter.enums.ScHqSysHqBillOneEnum;
import com.ruoyi.statisticalCenter.enums.ScHqSysHqBillTwoEnum;
import com.ruoyi.statisticalCenter.mapper.ScHqSysHqBillOneMapper;
import com.ruoyi.statisticalCenter.mapper.ScHqSysHqBillTwoMapper;
import com.ruoyi.statisticalCenter.service.ScHqSysHqBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ScHqSysHqBillServiceImpl implements ScHqSysHqBillService {
    @Autowired
    private ScHqSysHqBillOneMapper scHqSysHqBillOneMapper;
    @Autowired
    private ScHqSysHqBillTwoMapper scHqSysHqBillTwoMapper;

    @Override
    public List<ScHqSysHqBillOne> collect(ScHqSysHqBillOneVo vo) {
        PageHelper.startPage(vo.getPageDate());
        return scHqSysHqBillOneMapper.collect(vo);
    }

    @Override
    public List<ScHqSysHqBillTwo> collect(ScHqSysHqBillTwoVo vo) {
        PageHelper.startPage(vo.getPageDate());
        return scHqSysHqBillTwoMapper.collect(vo);
    }

    @Override
    public List<TableVo> initTable() {
        List<TableVo> list = new ArrayList<>();
        TableVo tableVo = new TableVo();
        String[] fields = {"businessDate", "chargeDate", "networkName", "scBusinessType", "income", "expend"
                };
        for (String field : fields) {
            tableVo = new TableVo();
            tableVo.setFields(field);
            list.add(tableVo);
        }
        for (TableVo vo : list) {
            vo.setTranslate(ScHqSysHqBillOneEnum.getValue(vo.getFields()));
        }
        return list;
    }

    @Override
    public List<TableVo> initTable2() {
        List<TableVo> list = new ArrayList<>();
        TableVo tableVo = new TableVo();
        String[] fields = {"scCostSubject", "income", "expend"
                };
        for (String field : fields) {
            tableVo = new TableVo();
            tableVo.setFields(field);
            list.add(tableVo);
        }
        for (TableVo vo : list) {
            vo.setTranslate(ScHqSysHqBillTwoEnum.getValue(vo.getFields()));
        }
        return list;
    }

}
